package com.sailfish.springbootdemo.dao.db1;

import com.sailfish.springbootdemo.common.DB1TableName;
import com.sailfish.springbootdemo.pojo.db1.PcbaDeviceResource;
import com.sailfish.springbootdemo.pojo.db1.PcbaLineRelatedDevice;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface PcbaLineRelatedDeviceDao {

    /**
     * 根据线体id查询所有
     * @param pcbaLineId
     * @return
     */
    /*@Results(id = "pcbaLineRelatedDeviceResultMap", value = {
            @Result(column = "pcba_line_related_device_id", property = "pcbaLineRelatedDeviceId", jdbcType = JdbcType.INTEGER),
            @Result(column = "pcba_device_id", property = "pcbaDeviceId", jdbcType = JdbcType.INTEGER),
            @Result(column = "pcba_line_id", property = "pcbaLineId", jdbcType = JdbcType.INTEGER),
            @Result(column = "sort", property = "sort", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "update_time", property = "updateTime", jdbcType = JdbcType.DATETIMEOFFSET),
    })
    @Select("select * from " + DB1TableName.PCBA_LINE_RELATED_DEVICE + " where pcba_line_id = #{pcbaLineId} order by sort")
    List<PcbaLineRelatedDevice> getAllByLine(@Param("pcbaLineId") Integer pcbaLineId);

    @ResultMap(value = "pcbaLineRelatedDeviceResultMap")
    @Delete("Select * from " + DB1TableName.PCBA_LINE_RELATED_DEVICE + " where pcba_line_id = #{pcbaLineId} and pcba_device_id = #{pcbaDeviceId}")
    List<PcbaLineRelatedDevice> getAllByLineAndDeviceResource(@Param("pcbaLineId")Integer pcbaLineId,@Param("pcbaDeviceId")Integer pcbaDeviceId);

    *//**
     * 根据pcbaLineId删除
     * @param pcbaLineId
     * @return
     *//*
    @Delete("delete from " + DB1TableName.PCBA_LINE_RELATED_DEVICE + " where pcba_line_id = #{pcbaLineId}")
    Integer deleteByLineId(@Param("pcbaLineId") Integer pcbaLineId);

    *//**
     * 根据线体id和 设备资源id 删除
     * @param pcbaLineId
     * @param pcbaDeviceId
     * @return
     *//*
    @Delete("delete from " + DB1TableName.PCBA_LINE_RELATED_DEVICE + " where pcba_line_id = #{pcbaLineId} and pcba_device_id = #{pcbaDeviceId}")
    Integer deleteByLineAndDevice(@Param("pcbaLineId")Integer pcbaLineId,@Param("pcbaDeviceId")Integer pcbaDeviceId);

    *//**
     * 插入
     * @param pcbaLineRelatedDevice
     * @return
     *//*
    @Insert("insert into " + DB1TableName.PCBA_LINE_RELATED_DEVICE + "(pcba_device_id,pcba_line_id,sort,create_time,update_time) values " +
            "(#{pcbaLineRelatedDevice.pcbaDeviceId},#{pcbaLineRelatedDevice.pcbaLineId},#{pcbaLineRelatedDevice.sort},#{pcbaLineRelatedDevice.createTime},#{pcbaLineRelatedDevice.updateTime})")
    Integer addPcbaLineRelatedDevice(@Param("pcbaLineRelatedDevice") PcbaLineRelatedDevice pcbaLineRelatedDevice);

    *//**
     * 更新
     * @param pcbaLineRelatedDevice
     * @return
     *//*
    @Update("<script>" +
            "update " + DB1TableName.PCBA_LINE_RELATED_DEVICE +
            "<set>" +
            "<if test='pcbaLineRelatedDevice.pcbaDeviceId != null and pcbaLineRelatedDevice.pcbaDeviceId != \"\" '>" +
            " pcba_device_id = #{pcbaLineRelatedDevice.pcbaDeviceId}," +
            "</if>" +
            "<if test='pcbaLineRelatedDevice.pcbaLineId != null and pcbaLineRelatedDevice.pcbaLineId != \"\" '>" +
            " pcba_line_id = #{pcbaLineRelatedDevice.pcbaLineId}," +
            "</if>" +
            "<if test='pcbaLineRelatedDevice.sort != null and pcbaLineRelatedDevice.sort != \"\" '>" +
            " sort = #{pcbaLineRelatedDevice.sort}," +
            "</if>" +
            "<if test='pcbaLineRelatedDevice.updateTime != null '>" +
            " update_time = #{pcbaLineRelatedDevice.updateTime}," +
            "</if>" +
            "</set>" +
            " where pcba_line_related_device_id = #{pcbaLineRelatedDevice.pcbaLineRelatedDeviceId}" +
            "</script>")
    Integer updatePcbaLineRelatedDevice(@Param("pcbaLineRelatedDevice") PcbaLineRelatedDevice pcbaLineRelatedDevice);


    *//**
     * 根据id查询
     * @param pcbaLineRelatedDeviceId
     * @return
     *//*
    @ResultMap(value = "pcbaLineRelatedDeviceResultMap")
    @Select("select * from " + DB1TableName.PCBA_LINE_RELATED_DEVICE + " where pcba_line_related_device_id = #{pcbaLineRelatedDeviceId}")
    PcbaLineRelatedDevice getPcbaLineRelatedDeviceById(@Param("pcbaLineRelatedDeviceId") Integer pcbaLineRelatedDeviceId);


    *//**
     * 查询所有已填写资产编号的设备
     *//*
    @Select("<script>" +
            "select * from " + DB1TableName.PCBA_LINE_RELATED_DEVICE + " where 1 = 1 " +
            "<if test='searchValue != null and searchValue != \"\" '>" +
            " and name like CONCAT('%',#{searchValue},'%')" +
            "</if>" +
            " and asset_number IS NOT NULL and asset_number != '' " +
            "</script>")
    @ResultMap(value = "pcbaLineRelatedDeviceResultMap")
    List<PcbaLineRelatedDevice> getPcbaLineRelatedDeviceResourceFilledAssetNumber(@Param("searchValue") String searchValue);*/
}
